const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
  mode: 'development',
  devtool: 'source-map',
  output: {
    filename: 'scripts/[name].[chunkhash:5].js',
  },
  plugins: [
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
      template: './public/index.html',
    }),
    new CopyPlugin([
      // 一个对象就是一个复制规则
      // 从 ./public 里的所有文件都复制到 dist 目录下
      // to 相当于就是 输出目录到
      // 如果 输出目录里面有相同文件了 就不会赋值了
      { from: './public', to: './' },
    ]),
  ],
};
